package com.hitgo.soccer.config;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.hitgo.soccer.core.Player;

public class TeamConfig
{

	public static Player[] players = null;
	
	public static void loadConfig(String configFile)
	{
		if (configFile == null || configFile.isEmpty())
			return;
			
		// 获取文档的根元素，赋值给rootElement变量
		Element rootElement = ConfigUtil.GetRootElement(configFile);
		if(rootElement == null)
			return ;
		
		NodeList nodeList = rootElement.getElementsByTagName("player");
		int nSize = nodeList.getLength();
		
		players = new Player[nSize];
		
		for(int nIndex = 0; nIndex < nSize; nIndex++)
		{
			Node nodeItem = nodeList.item(nIndex);
			if(nodeItem == null)
				continue ;
			
			short playerID = (short) ConfigUtil.GetAttributeIntValue(nodeItem, "id");
			
			Player player = new Player(playerID);
			
			players[nIndex] = player;
		}
	}
}
